package com.jinlia.show.modules.system.controller.sys;

import com.jinlia.show.modules.base.model.form.RoleForm;
import com.jinlia.show.modules.base.system.entity.SysRoleMenu;
import com.jinlia.show.modules.base.system.service.SysRoleMenuMapperService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("roleMenu")
public class SysRoleMenuController {

    private final SysRoleMenuMapperService sysRoleMenuMapperService;

    @PostMapping("getByRole")
    public ResponseEntity getByRole(@RequestBody RoleForm sysRoleMenu){
        List<SysRoleMenu> list = sysRoleMenuMapperService.lambdaQuery()
                .eq(SysRoleMenu::getRoleId, sysRoleMenu.getId() )
                .list();
        return ResponseEntity.ok(list);
    }
    @PostMapping("updateByRole")
    public ResponseEntity updateByRole(@RequestBody RoleForm sysRoleMenu){
        List<SysRoleMenu> list = sysRoleMenuMapperService.updateByRole(sysRoleMenu);
        return ResponseEntity.ok(list);
    }
}
